package com.haoqizhe.kernel.shiro.utils;

import cn.hutool.core.util.ObjectUtil;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * shiro 公共方法
 *
 * @author haoqizhe.li
 * @date 2021/01/18 14:54
 */
public class PasswordUtil {

    public static String encrypt(String password, String salt) {

        ByteSource credentialsSalt = ByteSource.Util.bytes(salt);
        Object obj = new SimpleHash("md5", password, credentialsSalt, 2);
        return ObjectUtil.isNotNull(obj) ? obj.toString() : "";
    }
}
